<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    *{
        padding: 0;
        margin: 0;
    }
    h3{
        text-align: center;
    }
    .goods{
        margin-top: 20px;
        display: flex;
        flex-wrap: wrap;
    }
    .list{
        display:flex;
        justify-content: center;
        flex:auto;
    }
</style>
<body>
    <!-- 作业：构建vue项目，写一个商品的列表，里面有图片链接等，可以用Vue里面的date的数据 -->
    <!-- 在原有的作业基础上，使用list遍历商品，每个商品初始为100个商品数量，给个input输入，输入1个对应的商品数据要-1，如果剩余数为0，则不展示-->
    <h3>商品信息</h3>
    <div class="goods">
        <div v-for="item in goodlist"  class="list">
            <div class="tu" v-if="(item.sumNum-item.buyNum)>0">
                <img width="300" height="250":src="item.image">
                <p>商品名称：{{item.name}}</p>
                <p>价格：{{item.price}}</p>
                <p>商品总数:{{item.sumNum}}</p>
                <p>商品剩余数量:{{item.sumNum-item.buyNum}}</p>
                请输入你要购买改商品的数量：<input type="text" v-model="item.buyNum">
            </div>
            <div v-else>
                <h4>{{item.name}}库存为0</h4>
            </div>
        </div>
    </div>
</body>
<script src="https://unpkg.com/vue@3.2.47/dist/vue.global.js"></script>
<script>
    Vue.createApp({
        data:()=>{
            return{
                goodlist:[
                    {name:"香蕉",status:1,price:10,buyNum:0,sumNum:100,image:"https://img0.baidu.com/it/u=1584398870,1120419115&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=500"},
                    {name:"草莓",status:1,price:15,buyNum:0,sumNum:100,image:"https://img2.baidu.com/it/u=3882505557,2873544715&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=500"},
                    {name:"番石榴",status:1,price:8,buyNum:0,sumNum:100,image:"https://img0.baidu.com/it/u=3507001014,1780056833&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=500"},
                ]
            }
        }
    }).mount("body")
</script>
</html>